How to format and structure your attributes and records to improve search results with Algolia.
title
attribute.
runtime
or aspect_ratio
. While they’re helpful in other contexts, they have little value when searching, filtering, ranking, or displaying search results.
While the names of the voice actors in the cast
attribute are helpful, you don’t need their birth date and place.
Therefore, you can safely remove them and just keep the names.
This process removes noise and saves room in records for more valuable data.
title
, synopsis
, director
, cast
, and genres
.
Algolia lets you define in which specific attributes to search, using the searchableAttributes
parameter.
By default, Algolia searches within the entire record, but you want to adjust this: this is better for performance and lets you remove noise.
Don’t search attributes that aren’t textually relevant or might generate false positives, like images
, release_year
, review_scores
, or country
.
For example, when searching for “japan”, English-speaking users most likely want to find movies that either have the term in the title or take place in Japan rather than Japanese movies.
You can therefore set title
, synopsis
, director
, cast
, and genres
as searchableAttributes
and leave out the rest for displaying, filtering, and custom ranking.
You can add extra data to improve the discoverability of your record.
For example, some users may look for a movie by its original title or translation in their language.
Unless the translations are in the record, searching for these terms would return no results, so it’s a good idea to retrieve them and add them to your objects.
You can fetch them from your database if you have them or a third-party source such as an API or a website.
title
and description
, can also be searchable.
Others, such as image
or likes
, shouldn’t be set as searchable.
director
, cast
, country
, content_rating
, and genres
and display them as refinement lists in your search experience, and release_year
to display a range slider.
Declare them with the attributesForFaceting
parameter.
Filterable attributes can be anything, but you should normalize your data to ensure consistency.
For example, if you have attribute genres
with the term “Animation” in one record and “Animated picture” in another, these would result in two different facet values.
A good rule of thumb is to add attributes based on how users want to fine-tune their search.
If you have a movie reviews website, users likely want to refine on review score or popularity.
objectID
in alphanumeric order, which isn’t helpful.
A better way to break ties is to compare meaningful information.
For movies, you could use the review_scores
attribute.
However, in the preceding example, you have several scores, you may want to compute them into a global one and use them in custom ranking.
The computed attribute would look like this: